#include <stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <iostream>
#include <unistd.h>
#include <string>

#define PATH "./"
#define ID 0x6666
#define SIZE 4096

using namespace std;

int main()
{
    int shmid = shmget(ftok(PATH,ID), SIZE, IPC_CREAT);
    char* shmaddr =  (char*)shmat(shmid,nullptr,0);

    int times = 10;
    while(times--)
    {
        std::cout << shmaddr << std::endl;
        sleep(1);
    }

    shmdt(shmaddr);
    shmctl(shmid, IPC_RMID, NULL);
    return 0;
}